package com.mytijian.code.service.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mytijian.code.enums.MerchantOrderStatusEnum;
import com.mytijian.code.exceptions.MashangExceptionEnum;
import com.mytijian.code.model.MerchantOrder;
import com.mytijian.exception.BizException;

public class MerchantOrderUtil {

	private static Logger logger = LoggerFactory.getLogger(MerchantOrderUtil.class);

	public static void validateOrderIsExpired(MerchantOrder order, String outerId) {
		if (order == null) {
			logger.info("此订单[outerId={}]码商处不存在", outerId);
			throw new BizException(MashangExceptionEnum.ORDER_NOT_EXIST);
		}
		if (order.getStatus() == MerchantOrderStatusEnum.UNNORMAL.getCode()) {
			logger.info("此订单[outerId={}]已作废", order.getOuterId());
			throw new BizException(MashangExceptionEnum.ORDER_WAS_INVALID);
		}
	}
}
